#include "widget.h"
#include "ui_widget.h"

#include <QResizeEvent>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    //设置label和widget一样大
    QRect rect=this->geometry();
    ui->label->setGeometry(0,0,rect.width(),rect.height());
    //设置label图片
    QPixmap pixmap(":/image/cloud.jpg");
    ui->label->setPixmap(pixmap);
    //设置图片大小
    ui->label->setScaledContents(true);

}

Widget::~Widget()
{
    delete ui;
}

void Widget::resizeEvent(QResizeEvent *event)
{
    ui->label->setGeometry(0,0,event->size().width(),event->size().height());
}

